export default function scrollTop (el, duration) {
  let currentScrollTop = el.scrollTop
  const height = Math.floor(el.clientHeight)
  const desScrollTop = el.scrollHeight - height
  const delta = Math.ceil(desScrollTop - currentScrollTop)
  function scroll () {
    currentScrollTop = currentScrollTop + (delta / (duration / 20))
    el.scrollTop = currentScrollTop
    if (currentScrollTop < desScrollTop) {
      requestAnimationFrame(scroll)
    }
  }
  scroll()
}
